package com.csap.framework.oauth2.context;

import com.csap.framework.oauth2.cache.RedisCacheQueryRequest;
import com.csap.framework.oauth2.cache.RedisCacheUpdateRequest;
import com.csap.framework.oauth2.impl.DataFunction;
import lombok.Builder;
import lombok.Data;

/**
 * @Author ycf
 * @Date 2022/3/10 5:40 PM
 * @Version 1.0
 */
@Data
@Builder
public class CacheApplicationData {
    /**
     * 查询
     */
    private RedisCacheQueryRequest<Object> queryRequest;
    /**
     * 修改
     */
    private RedisCacheUpdateRequest<Object> updateRequest;
    /**
     * 删除
     */
    private RedisCacheUpdateRequest<Object> removeRequest;

    /**
     * 数据
     */
    private DataFunction<Object> data;

    /**
     * 执行
     *
     * @param eleId 标识
     * @return 结果
     */
    public Object executeQuery(Long eleId) {
        return getQueryRequest().executeQuery(eleId, getData());
    }

    /**
     * 执行
     *
     * @param eleId 标识
     * @return 结果
     */
    public Object executeUpdate(Long eleId) {
        return getUpdateRequest().executeUpdate(eleId, getData());
    }
}
